﻿namespace SampleApplication
{
    #region Usings

    using CoffeeShopSample.Dependencies.Application;
    using CoffeeShopSample.Dependencies.Domain;
    using CoffeeShopSample.Implementation.Application;
    using CoffeeShopSample.Implementation.Application.CommandsParsers;
    using CoffeeShopSample.Implementation.Domain;
    using Microsoft.Practices.Unity;
    using System.Collections.Generic;
    using UnitTestInjector;

    #endregion Usings

    public static class DependenciesConfigurator
    {
        public static IDependencyResolver DependencyResolver()
        {
            var dependencyResolver = new UnityDependencyResolver(new UnityContainer());

            dependencyResolver.RegisterType<IConsole, Console>();
            dependencyResolver.RegisterType<IOutputWriter, Console>();
            dependencyResolver.RegisterType<IMenuWriter, MenuWriter>();
            dependencyResolver.RegisterType<ICommandParser, CommandParser>();
            dependencyResolver.RegisterType<IBootstrap, Bootstrap>();
            dependencyResolver.RegisterType<ICoffeeShop, CoffeeShop>();
            dependencyResolver.RegisterType<ICoffeeMachine, CoffeeMachine>();
            dependencyResolver.RegisterType<ITeaMachine, TeaMachine>();
            dependencyResolver.RegisterType<ICoffeeDispenser, CoffeeDispenser>();
            dependencyResolver.RegisterType<ITeaBagDispenser, TeaBagDispenser>();
            dependencyResolver.RegisterType<ICupFactory, CupFactory>();
            dependencyResolver.RegisterType<IApplication, WindowsApplication>();

            dependencyResolver.RegisterInstance<IEnumerable<ICommandParser>>(new List<ICommandParser>
            {
                dependencyResolver.Resolve<OrderCoffeeCommandParser>(),
                dependencyResolver.Resolve<OrderTeaCommandParser>(),
                dependencyResolver.Resolve<ExitCommandParser>(),
            });

            return dependencyResolver;
        }
    }
}